package cn.edu.scau.cmi.xiehaizhou.singleton;

import java.util.HashSet;
import java.util.Set;

import javafx.scene.control.Alert;

public class Marchal {
	private static Set<Marchal> marchals = new HashSet<Marchal>();
	private String name;
	private Marchal(String name)
	{
		this.name = name;
	}
	public static Set<Marchal> getMarchals(String name)
	{
		if(name.length() == 0)	return marchals;
		if(marchals.size()<10)
		{
			Marchal marchal = new Marchal(name);
			marchals.add(marchal);
		}
		else
		{
			Alert information = new Alert(Alert.AlertType.INFORMATION,"对不起，共和国只能有10个元帅\n" + name + 
					"不能再加入了");
			information.setHeaderText(null);
			information.showAndWait();
		}
		return marchals;
	}
	public String getName()
	{
		return name;
	}
}
